<%@ page language="java" pageEncoding="UTF-8" 
	import="com.ivo.model.hr.Employee"
%>
<%@ include file="/pages/common/taglibs.jsp" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	Employee user = (Employee)(session.getAttribute("LOGIN_USER"));
	
	String userId = "";
	String userName = "";
	boolean bMale = true;
	if(user!=null)
	{
		userName = "["+user.getId()+"] "+user.getName();
		userId = user.getId();
		
		bMale = user.getGender_FK().equals("1");
	}
%>

<jsp:useBean id="JSONRPCBridge" scope="session" class="org.jabsorb.JSONRPCBridge" />
<jsp:useBean id="jabsorbService" scope="session" class="com.ivo.jabsorb.JabsorbService" />

<%
	JSONRPCBridge.registerObject("jabsorbService", jabsorbService);
%>

<html>
  <head>
  	<title>新产品文件开发管理[Product Development Management]</title>
  	
  	<meta http-equiv="Page-Enter" content="blendTrans(Duration=4.0)">
  	
	<%@ include file="/pages/common/extjs.jsp" %>
	
	<link rel="stylesheet" type="text/css" href="${ctx }/ext-3.2/ux/css/ColumnNodeUI.css" />
    <script type="text/javascript" src="${ctx }/ext-3.2/ux/ColumnNodeUI.js"></script>
    
    <link rel="stylesheet" type="text/css" href="${ctx }/ext-3.2/ux/css/RowEditor.css" />
    <script type="text/javascript" src="${ctx }/ext-3.2/ux/RowEditor.js"></script>
    
    <link rel="stylesheet" type="text/css" href="${ctx }/ext-3.2/ux/treegrid/treegrid.css" rel="stylesheet" />
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/treegrid/TreeGridSorter.js"></script>
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/treegrid/TreeGridColumnResizer.js"></script>
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/treegrid/TreeGridNodeUI.js"></script>
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/treegrid/TreeGridLoader.js"></script>
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/treegrid/TreeGridColumns.js"></script>
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/treegrid/TreeGrid.js"></script>
	
	<script type="text/javascript" src="${ctx }/ext-3.2/ux/SearchField.js"></script>
    <script type="text/javascript" src="${ctx }/scripts/treeSerializer.js"></script>
    
    <!-- import JSONRPC -->
    <script type="text/javascript" src="${ctx }/scripts/jsonrpc.js"></script>
    
    <script type="text/javascript" src="${ctx }/pages/pdm/ProductDevelopmentManagement.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/EmployeeSelector.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/MemberMaintenance.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/CategoryModelManagement.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/Navigate.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/ProjectManagement.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/CategorySearch.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/TemplateManagement.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/ProjectMemberManagement.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/RoleManagement.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/SheetTemplateSetting.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/OwnerSelectionWindow.js"></script>
    <script type="text/javascript" src="${ctx }/pages/pdm/RoleUserSettingWindow.js"></script>
    
	<link type="text/css" rel="stylesheet" href="${ctx }/styles/pdm/all.css" />
	
    <link rel="stylesheet" type="text/css" href="${ctx }/styles/ext-button.css" rel="stylesheet" />
	
	<style type="text/css">
		.x-grid3 .x-window-ml{
			padding-left: 0;	
		} 
		.x-grid3 .x-window-mr {
			padding-right: 0;
		} 
		.x-grid3 .x-window-tl {
			padding-left: 0;
		} 
		.x-grid3 .x-window-tr {
			padding-right: 0;
		} 
		.x-grid3 .x-window-tc .x-window-header {
			height: 3px;
			padding:0;
			overflow:hidden;
		} 
		.x-grid3 .x-window-mc {
			border-width: 0;
			background: #cdd9e8;
		} 
		.x-grid3 .x-window-bl {
			padding-left: 0;
		} 
		.x-grid3 .x-window-br {
			padding-right: 0;
		}
		.x-grid3 .x-panel-btns {
			padding:0;
		}
		.x-grid3 .x-panel-btns td.x-toolbar-cell {
			padding:3px 3px 0;
		}
		.x-box-inner {
			zoom:1;
		}
		.x-grid-back-ux-gray {     
			background: #BDD3F7;
		}
		.x-grid-back-red {  
			background: #FF0000;  
		}
		.x-grid-back-light-color {  
			background: #EFF3FA;  
		}
		.x-grid-status-ux-yellow {     
			background: #FFFF00;
		}
		.x-grid-status-ux-red {     
			background: #FF0000;
		}
		.x-grid-status-ux-green {     
			background: #00FF00;
		}
		.x-grid-status-ux-gray {     
			background: #EAEAEA;
		}
	</style>
	
	<script type="text/javascript">
		window.basePath = '<%=basePath%>';
		var logined = '<%=user!=null%>';
		
		var roleName = getUserRoleName('<%=userId%>');
		
		Ext.onReady(function(){
		    Ext.BLANK_IMAGE_URL = "${ctx }/ext-3.2/resources/images/default/s.gif";
			Ext.QuickTips.init();
		    Ext.form.Field.prototype.msgTarget = 'side';
		    
		    var tb = new Ext.Toolbar({height:25});
		    
			tb.add("当前用户：","-",
				"<%=bMale ? "<img src='../../images/pdm/user_business.png' />":"<img src='../../images/pdm/user_female.png' />"%>",
		    	"<%=userName%>",{
		    		xtype: 'tbspacer', width: 130
		    	},
		    	"<img src='../../images/pdm/administrator.png' />",
		    	"系统管理员:  朱雪琴",
		    	"-",
		    	"RD 产品研发中心","-","<img src='../../images/pdm/building.png' />", "研发大楼二楼", "-", "<img src='../../images/pdm/telephone.png' />", "17429",
		   		"->",
			    {
	            	text: "退出",
	            	iconCls: 'cls_logout',
	            	tooltip: "退出登录", 
	            	handler: function(){
	            		logout();
	            	}
	            });
        	tb.render('toolbar');
        	
		    if(logined == "false")
		    {
		    	Ext.Msg.alert("温馨提示:", "您还没有登录！", function(){
		    		window.location = "<%=request.getContextPath()%>/login.jsp";
		    	});
		    }
		    
			new Ext.Viewport({
			    title: "Project Development Management",
				layout: 'border',
				items: [
					new Ext.Panel({
						border: false,
						region: 'north',
						layout: 'fit',
						height:	72,
						items: new Ext.BoxComponent({
							el: 'pdm_head',
							height: 25
						})
				}),{
					region: 'center',
					border: false,
					layout: 'fit',
					items:[{
						id: 'tabs',
						xtype: 'tabpanel',
						enableTabScroll: true,
						activeTab: 0,
						items:[{
							id: 'home_tab',
							title: "主页",
							iconCls: 'cls_home_house',
							region: 'center',
							layout: 'fit',
							html: '<iframe src=\"'+window.basePath+'pages/intro/intro.html\" width=\"100%\" height=\"100%\" frameborder=0 scrolling=auto></iframe>'
						}]
			        }]
				},new MenuPanel({_cur_user_id: '<%=userId%>',userRole: roleName})]
			});
			//根据角色显示未完成待办事项
			if(roleName=="project_owner"||roleName=="project_member")
			{
				createUnfinishedTabPnl();
			}
		});
/** =======================================================
 *  Function
 ** ==================================================== */
	String.prototype.replaceAll = function(s1,s2){
    	return this.replace(new RegExp(s1,"g"),s2);   
  	}
/********************************************************************************/	
	function renderString(a){
   		a = a.replaceAll("@39;","\'");
   		a = a.replaceAll("@34;","\"");
   		a = a.replaceAll("@13;","\n");
   		return a;
	}
/********************************************************************************/	
	function renderGridStr(a){
   		a = a.replaceAll("@39;","\'");
   		a = a.replaceAll("@34;","\"");
   		a = a.replaceAll("@13;"," ");
   		return a;
	}
/********************************************************************************/
	function logout()
	{
		Ext.Ajax.request({
			method: 'post',
			url: window.basePath + '/auth.go?method=logout',
			success: function(response,options)
			{
				window.location = window.basePath+"/login.jsp";
			},
			failure: function(response)
			{
				window.location.reload(true);
			}
		});
	}
/********************************************************************************/
	function getEditUserRoleInfo(cur_role_id){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var info = jsonrpc.jabsorbService.getEditUserRoleInfo(cur_role_id);
		}catch(e){
			alert(e);
		}
		var jsonInfo = eval("("+info+")");
		return jsonInfo;
	}
/********************************************************************************/
	function getRoleUserList(roleId, projectId){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var info = jsonrpc.jabsorbService.getRoleUserList(roleId, projectId);
		}catch(e){
			alert(e);
		}
		return info;
	}
/********************************************************************************/
	function getCateOwnerList(cateId, type){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var info = jsonrpc.jabsorbService.getCateOwnerList(cateId, type);
		}catch(e){
			alert(e);
		}
		return info;
	}
/********************************************************************************/
	function getUserRoleName(userId){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var roleName = jsonrpc.jabsorbService.getUserRoleName(userId);
		}catch(e){
			alert(e);
		}
		return roleName;
	}
/********************************************************************************/
	function getDefaultUserList(roleId){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var info = jsonrpc.jabsorbService.getDefaultUserList(roleId);
		}catch(e){
			alert(e);
		}
		return info;
	}
/********************************************************************************/
	function getProjectOwnerList(cateId){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var info = jsonrpc.jabsorbService.getProjectOwnerList(cateId);
		}catch(e){
			alert(e);
		}
		return info;
	}
/********************************************************************************/
	function getCatePathName(node)
	{
		var pathName = "";
		
		var json = node.toJsonString(null,
			function(key, val) {
				return (key == 'name');
			}, {
				name: 'text'
			}
		);
		var obj = eval("("+json+")");
		pathName = obj.text;
		var parent = node.parentNode;
		
		while(parent.getDepth()>0)
		{
			var parentJson = parent.toJsonString(null,
				function(key, val) {
					return (key == 'name');
				}, {
					name: 'text'
				}
			);
			var parentObj = eval("("+parentJson+")");
			pathName = parentObj.text + " >> " + pathName;
			parent = parent.parentNode;
		}
		
		return pathName;
	}
/********************************************************************************/
	function createUnfinishedTabPnl()
	{
		var objTabs = Ext.getCmp('tabs');
		var objMyOnhandFileSearchTab = Ext.getCmp("my_onhand_file_tab");
		if(typeof(objMyOnhandFileSearchTab)=='undefined')
		{
			var pnl_myOnhandFile = Ext.getCmp("myOnhandDocumentGrid");
			if(typeof(pnl_myOnhandFile)=='undefined')
			{
			  	pnl_myOnhandFile = new MyOwnDocument({id: "myOnhandDocumentGrid", _cur_user_id: '<%=userId%>', _unfinished: true});
			}
			objTabs.add({
				title: "我的未完成文件",
				id: 'my_onhand_file_tab',
				region: 'center',
				closable: true,
				layout: 'fit',
				border: false,
				frame: false,
				border: false,
				iconCls: 'cls_unfinished_document',
				items: [pnl_myOnhandFile]
			});
			objTabs.getLayout().setActiveItem("my_onhand_file_tab");
			objTabs.doLayout();
			
			pnl_myOnhandFile.load('<%=userId%>');
		}else{
			objMyOnhandFileSearchTab.show();
		}
	}
</script>

	</head>
	<body leftmargin=1 rightmargin=1 topmargin=1 bottommargin=1>
		<div>
			<input id=_selected_node_id name =_selected_node_id type=hidden value="" />
			<input id=_selected_node_text name =_selected_node_text type=hidden value="" />
		</div>
		<div id = "renameFolder">
			<input id=_selected_project_id name =_selected_project_id type=hidden value="" />
		</div>
		<div id = "hidden_EditRole">
			<input id=_selected_role_id name =_selected_role_id type=hidden value="" />
		</div>
		<div id = "hidden_Employee_Selector">
			<input type="hidden" id="_select_employee" name="_select_employee" value=""/>
			<input type="hidden" id="_collectReCosign" name="_collectReCosign" value=""/>
		</div>
		<div id = "hidden_dispatch_project_owner">
			<input type="hidden" id=_selected_pro_id name =_selected_pro_id value="" />
			<input type="hidden" id="_select_owner" name="_select_owner" value=""/>
			<input type="hidden" id="_collectOwners" name="_collectOwners" value=""/>
		</div>
		<!-- used for setting project's role users -->
		<div id = "hidden_dispatch_project_user_role">
			<input type="hidden" id="_collectUsers" name="_collectUsers" value=""/>
		</div>
		<!-- used for setting role's default users -->
		<div id = "hidden_dispatch_default_user">
			<input type="hidden" id="_defaultUsers" name="_defaultUsers" value=""/>
		</div>
		<div id="pdm_head">
			<div class="pdm_hta" id="pdm_header">
				<div class="pdm_hg" style="background-image: url(${ctx }/images/app/g.png);">
					<div class="pdm_h pdm_hfixwth">
						<img src="${ctx }/images/pdm/my_pdm.png" style="margin-top: 10px; margin-left: 2px;" align=left />
					</div>
				</div>
			</div>
			<div id="toolbar"></div>
		</div>
		
		<div id="user_info">
			<input type=hidden id="userId" name="userId" value="<%= userId %>" />
		</div>
		
	</body>
</html>